package com.hbnu.exception;

import java.util.Scanner;

public class ExceptionDemoTest1 {
    //已经知道用户名和密码，请用程序实现模拟用户登录，总共给三次机会，登录之后，给出相应的提示。
    public static void main(String[] args) {
        String username = "root";
        String password = "12123";

        Scanner scanner = new Scanner(System.in);
        int flag = 0;
        while(flag<3){
            String username_in = scanner.nextLine();
            String pasword_in = scanner.nextLine();
            if(username_in.equals(username) && pasword_in.equals(password)){
                break;
            }
            System.out.println("重新尝试");
            flag += 1;
        }
        if(flag<3){
            System.out.println("登陆成功");
        }
        else{
            System.out.println("登录失败，次数耗尽。");
        }
    }
}
